﻿using System;
using System.Collections.Generic;
using System.Text;

namespace Maniac
{
    public class HistoricalPrice
    {
        private string ivsSymbol;
        public string Symbol
        {
            get
            {
                return ivsSymbol;
            }
            set
            {
                ivsSymbol = value;
            }
        }

        private decimal iviOpenPrice;
        public decimal OpenPrice
        {
            get
            {
                return iviOpenPrice;
            }
            set
            {
                iviOpenPrice = value;
            }
        }

        private decimal iviHighPrice;
        public decimal HighPrice
        {
            get
            {
                return iviHighPrice;
            }
            set
            {
                iviHighPrice = value;
            }
        }

        private decimal iviLowPrice;
        public decimal LowPrice
        {
            get
            {
                return iviLowPrice;
            }
            set
            {
                iviLowPrice = value;
            }
        }

        private decimal iviClosePrice;
        public decimal ClosePrice
        {
            get
            {
                return iviClosePrice;
            }
            set
            {
                iviClosePrice = value;
            }
        }
        private decimal iviPriorClosePrice;
        public decimal PriorClosePrice
        {
            get
            {
                return iviPriorClosePrice;
            }
            set
            {
                iviPriorClosePrice = value;
            }
        }
        /// <summary>
        /// Yahoo provides the adjusted closing price for each day.
        /// </summary>
        private decimal ivdCloseAdjustedPrice;
        public decimal CloseAdjustedPrice
        {
            get
            {
                return ivdCloseAdjustedPrice;
            }
            set
            {
                ivdCloseAdjustedPrice = value;
            }
        }

        private long iviVolume;
        public long Volume
        {
            get
            {
                return iviVolume;
            }
            set
            {
                iviVolume = value;
            }
        }

        private int iviMonth;
        public int Month
        {
            get
            {
                return iviMonth;
            }
            set
            {
                iviMonth = value;
            }
        }

        private int iviDay;
        public int Day
        {
            get
            {
                return iviDay;
            }
            set
            {
                iviDay = value;                
            }
        }

        private DateTime ivdDate;
        public DateTime Date
        {
            get
            {
                return ivdDate;
            }
            set
            {
                ivdDate = value;
            }
        }

		private int iviSession;
        public int Session
        {
            get
            {
                return iviSession;
            }
            set
            {
                iviSession = value;
            }
        }

        private int iviYear;
        public int Year
        {
            get
            {
                return iviYear;
            }
            set
            {
                iviYear = value;
            }
        }
        [System.Xml.Serialization.XmlIgnore]
        public decimal GainIntraday
        {
            get
            {
                if (!ivdGainIntraday.HasValue)
                {
                    ivdGainIntraday = Math.Round((this.ClosePrice - this.OpenPrice), 2);
                }
                return ivdGainIntraday.Value;
            }
            set
            {
                ivdGainIntraday = value;
            }
        }
        [NonSerialized]
        private decimal? ivdGainIntraday;
        [System.Xml.Serialization.XmlIgnore]
        public decimal GainIntradayPercent
        {
            get
            {
                if (!ivdGainIntradayPercent.HasValue)
                {
                    ivdGainIntradayPercent = Math.Round((this.GainIntraday * 100 / this.OpenPrice), 2); 
                }
                return ivdGainIntradayPercent.Value;
            }
            set
            {
                ivdGainIntradayPercent = value;
            }
        }
        [NonSerialized]
        private decimal? ivdGainIntradayPercent;
        [System.Xml.Serialization.XmlIgnore]
        public decimal GainPriorClose
        {
            get
            {
                if (!ivdGainPriorClose.HasValue)
                {
                    ivdGainPriorClose = Math.Round((this.ClosePrice - this.PriorClosePrice),2);
                }
                return ivdGainPriorClose.Value;
            }
            set
            {
                ivdGainPriorClose = value;
            }
        }
		private bool ivbIsExDividendDate;
		public bool IsExDividendDate
		{
			get
			{
				return ivbIsExDividendDate;
			}
			set
			{
				ivbIsExDividendDate = value;
			}
		}
        [NonSerialized]
        private decimal? ivdGainPriorClose;
        [System.Xml.Serialization.XmlIgnore]
        public decimal GainPriorClosePercent
        {
            get
            {
                if (!ivdGainPriorClosePercent.HasValue)
                {
                    if (this.PriorClosePrice > 0)
                        ivdGainPriorClosePercent = Math.Round((this.GainPriorClose * 100 / this.PriorClosePrice), 2);
                    else
                        ivdGainPriorClosePercent=0;
                }
                return ivdGainPriorClosePercent.Value;
            }
            set
            {
                ivdGainPriorClosePercent = value;
            }
        }
        [NonSerialized]
        private decimal? ivdGainPriorClosePercent;
    }
}
